package com.example.port.mapper;

import com.example.port.entity.Invoice;
import com.example.port.entity.StorageFee;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface InvoiceMapper {
    
    int insert(Invoice invoice);
    
    List<Invoice> selectAll();
    
    Invoice selectById(@Param("id") Long id);
    
    // 关联仓储费用和发票
    int linkFeeToInvoice(@Param("feeId") Long feeId, @Param("invoiceId") Long invoiceId);
    
    // 查询发票关联的仓储费用
    List<StorageFee> selectInvoiceFees(@Param("invoiceId") Long invoiceId);
    
    // 更新发票信息
    int update(Invoice invoice);
    
    // 获取最大发票ID
    Long getMaxInvoiceId();
    
    // 删除发票
    int delete(@Param("id") Long id);
    
    // 解除费用与发票的关联
    int unlinkFee(@Param("feeId") Long feeId);
    
    // 查询某个费用关联的发票ID
    Long getInvoiceIdByFeeId(@Param("feeId") Long feeId);
    
    // 检查发票是否还有关联的费用
    int countInvoiceFees(@Param("invoiceId") Long invoiceId);
} 
